// Allee and Peinhardt 2011 IO

// Load original dataset
clear
use "AP2011 IO Rep Data.dta"

// REPLICATION
summarize
display c(k)
mdesc
codebook year
codebook ifscode
gen elngdppc = exp(lngdppc)
gen flnfdi = F.lnfdi
gen fworldfdi = F.worldfdi

// Table 2
xtreg F.lnfdi bitcount cbdcrisis domestic1_8 external_conflict polity2 proprights lnpop_total lngdppc gdp_grow offxrate_lcudif kaopen F.worldfdi if oecd~=1, fe robust cluster (ifscode)
codebook year if e(sample)
codebook ifscode if e(sample)
mdesc flnfdi bitcount cbdcrisis domestic1_8 external_conflict polity2 proprights lnpop_total lngdppc gdp_grow offxrate_lcudif kaopen fworldfdi

xtreg  F.lnfdi bitcount pending cbdcrisis domestic1_8 external_conflict polity2 proprights lnpop_total lngdppc gdp_grow offxrate_lcudif kaopen F.worldfdi if oecd~=1, fe robust cluster (ifscode)
codebook year if e(sample)
codebook ifscode if e(sample)
mdesc flnfdi bitcount pending cbdcrisis domestic1_8 external_conflict polity2 proprights lnpop_total lngdppc gdp_grow offxrate_lcudif kaopen fworldfdi

xtreg  F.lnfdi bitcount numreg2 cbdcrisis domestic1_8 external_conflict polity2 proprights lnpop_total lngdppc gdp_grow offxrate_lcudif kaopen F.worldfdi if oecd~=1, fe robust cluster (ifscode)
codebook year if e(sample)
codebook ifscode if e(sample)
mdesc flnfdi bitcount numreg2 cbdcrisis domestic1_8 external_conflict polity2 proprights lnpop_total lngdppc gdp_grow offxrate_lcudif kaopen fworldfdi

xtreg  F.lnfdi bitcount numreg5 cbdcrisis domestic1_8 external_conflict polity2 proprights lnpop_total lngdppc gdp_grow offxrate_lcudif kaopen F.worldfdi if oecd~=1, fe robust cluster (ifscode)
codebook year if e(sample)
codebook ifscode if e(sample)
mdesc  flnfdi bitcount numreg5 cbdcrisis domestic1_8 external_conflict polity2 proprights lnpop_total lngdppc gdp_grow offxrate_lcudif kaopen fworldfdi

// IMPUTATION
clear
use "AP2011 IO Imp Data.dta"
summarize
mi import flong, m(imp) id(year ifscode) imp(lnfdi-fdi_inflows)

mi xtset ifscode year

// Table 2
mi estimate, post: xtreg F.lnfdi bitcount cbdcrisis domestic1_8 external_conflict polity2 proprights lnpop_total lngdppc gdp_grow offxrate_lcudif kaopen F.worldfdi if oecd~=1, fe robust cluster (ifscode)

mi estimate, post: xtreg  F.lnfdi bitcount pending cbdcrisis domestic1_8 external_conflict polity2 proprights lnpop_total lngdppc gdp_grow offxrate_lcudif kaopen F.worldfdi if oecd~=1, fe robust cluster (ifscode)

mi estimate, post: xtreg  F.lnfdi bitcount numreg2 cbdcrisis domestic1_8 external_conflict polity2 proprights lnpop_total lngdppc gdp_grow offxrate_lcudif kaopen F.worldfdi if oecd~=1, fe robust cluster (ifscode)

mi estimate, post: xtreg  F.lnfdi bitcount numreg5 cbdcrisis domestic1_8 external_conflict polity2 proprights lnpop_total lngdppc gdp_grow offxrate_lcudif kaopen F.worldfdi if oecd~=1, fe robust cluster (ifscode)
